package com.homeparking.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.homeparking.common.annotation.Log;
import com.homeparking.common.core.controller.BaseController;
import com.homeparking.common.core.domain.AjaxResult;
import com.homeparking.common.enums.BusinessType;
import com.homeparking.manage.domain.Daywork;
import com.homeparking.manage.service.IDayworkService;
import com.homeparking.common.utils.poi.ExcelUtil;
import com.homeparking.common.core.page.TableDataInfo;

/**
 * 员工工作日志信息Controller
 * 
 * @author liuyangyang
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/manage/daywork")
public class DayworkController extends BaseController
{
    @Autowired
    private IDayworkService dayworkService;

    /**
     * 查询员工工作日志信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:daywork:list')")
    @GetMapping("/list")
    public TableDataInfo list(Daywork daywork)
    {
        startPage();
        List<Daywork> list = dayworkService.selectDayworkList(daywork);
        return getDataTable(list);
    }

    /**
     * 导出员工工作日志信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:daywork:export')")
    @Log(title = "员工工作日志信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Daywork daywork)
    {
        List<Daywork> list = dayworkService.selectDayworkList(daywork);
        ExcelUtil<Daywork> util = new ExcelUtil<Daywork>(Daywork.class);
        util.exportExcel(response, list, "员工工作日志信息数据");
    }

    /**
     * 获取员工工作日志信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:daywork:query')")
    @GetMapping(value = "/{dayworkId}")
    public AjaxResult getInfo(@PathVariable("dayworkId") Long dayworkId)
    {
        return success(dayworkService.selectDayworkByDayworkId(dayworkId));
    }

    /**
     * 新增员工工作日志信息
     */
    @PreAuthorize("@ss.hasPermi('manage:daywork:add')")
    @Log(title = "员工工作日志信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Daywork daywork)
    {
        return toAjax(dayworkService.insertDaywork(daywork));
    }

    /**
     * 修改员工工作日志信息
     */
    @PreAuthorize("@ss.hasPermi('manage:daywork:edit')")
    @Log(title = "员工工作日志信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Daywork daywork)
    {
        return toAjax(dayworkService.updateDaywork(daywork));
    }

    /**
     * 删除员工工作日志信息
     */
    @PreAuthorize("@ss.hasPermi('manage:daywork:remove')")
    @Log(title = "员工工作日志信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dayworkIds}")
    public AjaxResult remove(@PathVariable Long[] dayworkIds)
    {
        return toAjax(dayworkService.deleteDayworkByDayworkIds(dayworkIds));
    }
}
